<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function(Blueprint $table)
        {
            $table -> increments('id')        ->comment('用户标识');
            $table -> string('username')      ->unique()->nullable()->comment('用户名');
            $table -> string('email')         ->unique()->nullable()->comment('用户邮箱');
            $table -> string('phone')         ->unique()->nullable()->comment('用户电话');
            $table -> string('wx_unionid')       ->unique()->nullable()->comment('unionid 针对微信登录用户');
            $table -> string('wx_openid')        ->unique()->nullable()->comment('openid 针对微信登录用户');
            $table -> string('wx_session_key') ->nullable()->comment('微信返回的状态');
            $table -> string('password')      ->comment('密码');
            $table -> string('reg_ip')        ->comment('注册ip');
            $table -> timestamp('reg_time')   ->comment('注册时间');
            $table -> string('login_ip')      ->nullable()->comment('最后登录ip');
            $table -> timestamp('login_time') ->nullable()->comment('最后登录时间');
            $table -> integer('login_count')  ->nullable()->comment('登录次数');
            $table -> integer('role')         ->default(0)->comment('登录角色');
            $table -> integer('status')       ->default(1)->comment('用户状态,0锁定,1正常');
            $table -> rememberToken();
            $table -> softDeletes();
            $table -> timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //
    }
}
